﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BaseData;
using BaseData.Exts;
using BaseLib.Helper;
using BaseUtility;

namespace WebUI.Ashx.Acc.Staff
{
    /// <summary>
    /// GroupAdminInfoView 的摘要说明
    /// </summary>
    public class GroupAdminInfoView : Base, IHttpHandler
    {
        private static readonly AccClass _accId = new AccExts(new GetAccType().Parse(Request.QueryString["url"])).Instances;
        public void ProcessRequest(HttpContext context)
        {
            if (_accId.Id == 0 || string.IsNullOrWhiteSpace(_accId.Name) || _accId.Type == 0) return;
            using (var ctx = new ContextExt())
            {
                var action = (Enums.Action)Enum.Parse(typeof(Enums.Action), Request.QueryString["action"]);
                var id = Request.QueryString["id"].ToInt(0);
                var items = from q in ctx.Web_Base_News_Info select q;
                items = action == Enums.Action.ActReply ? items.Where(w => w.ParentId == id) : items.Where(w => w.PkId == id);
                if (items.Any()) context.Response.Write(items.FirstOrDefault().ObjectsToJson());
            }
            context.Response.ContentType = "text/plain";
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}